#ifndef __SPI_H
#define __SPI_H
#include"define.h"

void SPI0_Init(void);
void CS(uint8 t);
void delay_us(uint32 us);
void Wait_bsy(void);
void Write_Enable(void);
void Write_Disenable(void);	
uint8 ReadSR(void);
void WriteSR(uint16 t);
uint16 ReadID(void);
void Read_Flash(uint16 n);

void Fastread_Flash(uint16 n);
void Fastread_dual_Flash(uint16 n);
//void Write_Page(uint16 n);
void Erase_Chip(void);	
void Sector_Chip(void);
void Block_Chip(void);
void Write_Page_AAI(uint16 n);
void WRSR(void);
void Flash_Wait_Busy(void) ;

void SPI1_Init(void);
void CS1(uint8 t);	
void SPI1_ReadWriteByte(uint8 TxData);	
void Wait_bsy1(void);
void Write_Enable1(void);
void Write_Disenable1(void);
void ReadSR1(void);
void WriteSR1(uint16 t);
void ReadID1(void);
void Read_Flash1(uint16 n);
void Fastread_Flash1(uint16 n);
void Fastread_dual_Flash1(uint16 n);
void Write_Page1(uint16 n);
void Erase1_Chip(void);	
void Sector1_Chip(void);
void Block1_Chip(void);

void SPIslave_Init(void);
void SPIslave1_Init(void);

void Write_PageAAI(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);
uint8 SPI_ReadWriteByte(uint8 TxData);
void Flash_Read(uint8* pBuffer,uint32 ReadAddr,uint16 NumByteToRead);
void Write_Page(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);
void Write_NoCheck(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);  
void Flash_Write(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);
void Erase_Sector(uint32 Dst_Addr) ;

uint8 SPI_1_ReadWriteByte(uint8 TxData);
void Write_Page_1(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);
void Flash_Read1(uint8* pBuffer,uint32 ReadAddr,uint16 NumByteToRead);
void Write_NoCheck1(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);   
void Flash_Write1(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);
void Erase_Sector1(uint32 Dst_Addr) ;
void csH(int csStatus);
#endif



